Cleanup and general improvements to code
Merge branch 'SPA' of https://github.com/SK-RnD/EMC.git