Fixed out of memory exceptions and fixed opening and saving