Refactoring

Working towards functional first release
Refactoring