Refactoring

Same functionality, vastly (imho) improved code