Fix exceptions.

Use correct field name: packet.block_metadata.
Correct use of window id and window type.
Reduce parameter passing by using nonlocal.
Remove unused file.