Rewritten all code according to style conventions.