added more cross-platform code in the Surface object