Fix #17 thoroughly