Splitting into multiple files, other reorganization
Internal handlers now use deferreds