Fix #157 and some beautifications