Adding functions
Some fixes