Refactor; Syntax cleanup, Naming changes, Memory Management fixes

I've modernized the code a little bit, (there is a lot more to do), cleanup up memory issues. Standardized syntax across files.

Merged other useful pull-requests from @AriX @benoitsan @ejensen 

Needs testing before merge.