Major cleanup, removed most C-style code
Cleaning up some more stuff, and save the pattern used