Refactor to simplify codes
Define delegate protocol in header files
Remove unused codes