Object oriented total refactoring

Completely refactored code aiming to be a little bit more object oriented. No functionality has been added nor removed.