massive code cleanup & new design
conversion to em