Bugfixes + code semplification

Simplicity is always the best!