Split up files more sanely

Header + implemenation. It's not completely done, though (config.h
lingers).