Fixed several bugs and changed AddFunction for Contents to JSONRESULT