Optimize

Once this is done, #23 can be closed.