Various changes and new functions