fixed many bugs, production ready