Adjustments

Various adjustments, reorganization of code