Forward port

Pull in changes in ckolivas/cgminer (up to commit 8fa5ddfd2ca581d30ec21ade08332294b481d31c, made on Wed Nov 13 11:57:29 2013 +0100).

This is still useful for all functionality not related to SHA256d/Scrypt mining. Obviously, ckolivas/cgminer developers are few bits more familiar with the code base.