reformatted to code style and added some missing semis