Re-wrote mining logic. seems much better.