Added sanity checks for incoming parameters