Little refactoring. Also there is more segfaults, segfaults, everywhere...