Improved functions, classes, etc, other minor changes