I need to pass a node id to a block
Not quite a block, but you can do this with custom panel panes and pass it the $node being viewed.  This is the cleanest way.  I don't have a link handy for an overview on how to do this, though.

You can also do something similar using a view, and wiring up the relationships / arguments appropriately.  You can then stick this view into a panel pane.

The hack is do do something like this in your block code

if (arg(0) == "node" &amp;&amp; arg(2) != "edit") {
  $nid = (int) arg(1);
  if ($nid) {
    // do stuff
  }
}