add restapi module, and do some cleanup