merged some similar modules, removed some useless bits, lots of code cleanup