Cleaned added comments. fixed small issues. added copy sql to memory option