Major refactoring and way better docs