Fixed several bugs for deployment