Code style and some fixes