Fixes #81 by adding more typesafness