Added some functions and more type control