Refactor code more

Take a look.