Serious refactoring.
update