cleanup and structure more. Also added some more selenium tests for UI.