Fix bugs in deploy system