Adjust to coding conventions and add some changes