Added better resource management + del 1st lines.