More checks when writing to ram. Fixes #62