pie code clean up