Fix map/unmap code to follow mmap/munmap semantics more closely

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Add basic clean-up in library destructor

This is enough to close all BOs if the application terminates
correctly, leaving some objects open.

Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>