added many functions
cleanup/bug fix