Revert "rewrite to do things right and not suck so much"

This reverts commit 537d31678119d20318e1cc0900a8063d0d4c2fc8.