Source cleanup and fixes