Added input validation and safties. More to come.