Added some validation / bugfixes