Cleaned up miner code