Added some sanity checking... This is horribly hacky :-/