Fixed VS2008 compil issues and some cleanups