Use StringBuilder instead of StringBuffer

Synchronization is not needed in this static context.
Remove usage of StringBuilder as it's unneeded

There are no advantages here, only disadvantages.
Remove redundant casts
Replace manual array copy with System.arraycopy()

This approach is more efficient.
Merge pull request #125 from goncalossilva/minor_cleanup

Minor cleanup