Massive refactoring & refinements; WIP
Fixed all found errors
Fixed main header
fix