add more functions
add some docs, fix some warnings etc.