Some minor tweaks, add bounds check for texture sample