fixed memory menagement and window resizeing