fixed a lot of bugs and changed design.