Clean-up

Cleaned-up some code, improved extensibility