Some changes and refactoring :P