Reworking to make it compile on VS2013