Clean up server package.

 * Remove unused `types.go' file.
 * Split library and catalog code into smaller parts.
Fix new origins handling on server reload.