Throw IllegalArgumentException where necessary