Merged from changes and bug fixes devel branch. Applied formatting rules.