Fixed bugs

See comments in Redmine for each ticket. Some require further development.