Some refactoring done, on to memory leaks
Merge branch 'refactoring' into devel
Memory leaks cleared~
Merge branch 'memory_leak' into devel