Make this work on Windows (Visual c++ Express 2008). Kept original lines as comments