Bug fixes

Will be merged on 08/26. Please, comment on possible issues.