Cleanup; fixed issue with hanging at end; simplified and fixed regex parsing of inline commands/optional parameters.