Cleaned up the code a bit

Cleaned up the layout of the code a bit and removed redundant
unallocates, try running it again