Added tree serialization; fixed q4.1