Added topSort functions, cleaned up some mistakes