Add .gitignore.
Add type signatures to please HLint.
Handle edge case in topological sort.