moved some code from server to global. stcg computation. gains summary tab loaded with sqldf