Code cleanup, finalizing locals and such