Handle wrong keys better. Fixes #3 and #15