Code formatting and minor polishing