Optimize

Optimizing a bit, biggest gain was from https://github.com/kesla/medea/commit/a02762c7c76840413d940e6b2f2669186240add3

Also, based on #15, so merge that first.