Fix NoMethodError caused by nil notebookCounts
counts.notebookCounts returns nil when all notebooks are empty
Use 1.9 hash syntax everywhere
Ruby style fixes
refactoring