Fixed linking problems and testing again.
Fixed use of substr. Testing again.