Cleanup code relative to bitstream.

Remove lots of unnecessary malloc, free and assignment.