Better tracking of peer state in peer database
Explicit casts when converting from 64 to 32-bit integers

Conflicts:
	libraries/rpc/rpc_server.cpp
Minor fixes to get the new branch compiling on win32