Refactoring

major refactoring, stripping out excess functionality