Add core app logic, various fixes