moved common api function to lib classes, added flot charts, and some other stuff