Fix #39 and some cleanup