Massive code refactor/bug-fix release