popup bug fix and cleanup