Add extra checks to buffer mapping