Attempt cleanup and reimplementation
Fix bugs...