Minor refactorings

Refactored to make the code a bit more easy to read.