Added support for arbitrary surface sizes.