backport fixes from cgminer, changed version number to 0.5.0