Some small bug fixes and improvements

First off, sorry that all three of these commits are in one pull request. I apparently do not understand GitHub yet.

(1) I noticed that the 'static' styles were being appended in each iteration of the loop, rather than once at the end.
(2 + 3) Empty string and null values caused weird behavior.