Fix bugs from Redmine #1, #6, #11