Implement buffer mapping

Does a big part of #236