Re-arranged code order, and added spass debug