Added function to copy Ptrees, enabled Wall and Werror and fixed misc errors