Revert "Import fixes from Michael for Arduino 1.5.7"

This reverts commit f8a97debce5b795a2a9f30fa24a00fd754932af8.
Revert "Revert "Import fixes from Michael for Arduino 1.5.7""

This reverts commit 86cf109fd39b3687f03aa59963506d75a77cd70c.
Merge commit '7bb1a2c146bb2be4ad693b5df3f128bf9e4a2495'