More Security Checks and Error Handling