added getObstacles function and slightly optimized obstacle handling