added popup size computation, added comments and removed unneeded objects