I have also had issues when the switch is not level. I use a plastic straight edge and lay it across the switch rails in all directions, and from inside to outside rails to be sure the switch is sitting flat on the table. Also check the tracks going into and out of the switch to be sure they are level as well.
If the wheels are on the verge of touching or not touching the rails, you can get issues. My problem was that at very slow speeds, the engine would stall on the switch. This may not cause sparking at the wheels, however it may be worth checking out anyway.
Good luck. Remember, troubleshooting is fun!