Reorganizing project, and several bugfixes.