Added proper include functions
Added some parameter error checking