Moved init code into constructors and destruction into destructors

I have no idea if this works(I did get it to compile to a .so) and I don't fell like trying to test it right now. Kappa

C++ has class constructors and destructors for a reason so I made use of them and I did some other things.
I will take a better look at the code later to see what else I can add or change.