Mining fixes, optimization

Hooray.