First commit

Some cleaning and refactoring over the original version