better memory management; added multistage preselection