Improved error handling, added card handling module