Bug fixes and code cleanup from separating client and server pieces.