Fixed bugs and coding style.