Added some bytecode related utilities.
Spent a totally justified amount of time tweaking hat-related logic.