Basic optimization

Around 20x performance boost.
Remove cruft