Memory management refactoring
Merge changes
Fix issues with vector overrun, dealloc calls.
Gaddamn stupid headers
IO refactory, test cases for factory