Did some bug fixes. Need to change pop db query