Rewrited some code to match the coding conventions.