Fixed results and some refactoring