Added handling for entries with spaces. A bit of cleanup