Fixed bugs and finished the ui part.
Still need more testing.