Big refactor, still needs some cleaning
Incremented patch number.