Fixed some bugs to scalability