Added showDialog, fixed resource usage