Fixed select all functionality, more code cleanup