added basic building, fixed many bugs, made many code improvements