Complete refactoring and overhaul

merge develop