Improved error handling, added full key mapping.