Fixed bug in function BrowseForFolder
Clean up code