Replaced all KeyErrors by actual exceptions, fixes #247