Fixed the issues and added a couple of more detailed checks.