Refactor frame type, move more stuff into connection module.