Added a few functions and fixes