Added basic safegaurds to prevent bad use.