Changed finish button handling, some refactoring