In over my head, but I thought you couldn't use 14ga wire for anything over 20a at 120v, that 12ga would be the minimum, and for 40a I'm surprised you don't HAVE to run 12ga.
For 30A 240v, I believe you must be running 10ga. but I could be wrong.