added spawn trigger and fixed bugs