Fixed and added more sanity and validation