Reorganize structure and add basic mail support