fix a recursion issue and some typos, thanks @riobard for reporting it