Cleanup: move non UI code from Main project  into utilities project

Moving all non UI code from main project into utilities. Will do the
same for other projects eventually, then will further organize the
common code.