Make function signatures more precise

- also use utils.map in few places more