Some refactoring, tons of comments