Added several tool functions
Fixed some problems