Fix #13 and some cleanup.