BROKEN. Started refactoring and need to finish and make it work again.