Removed unnecessary whileloop
Refactored drawing and fixing memoryleak