An Error Was Encountered

When I've install application with empty database I saw only 'An Error Was Encountered' message. The problem was in empty database, some conditions worked incorrectly. I've made fixes for that. Description in commit messages.