Some optimizations

Ref #28