pack tree functions and fix background moving bugs