Greatly refactored rendering code and fixed several bugs.

Added dynamic text wrapping and margin setting.

Closes #9 
Closes #10
Closes #18 
Closes #19