Huge refactoring of the database, use channels instead of single buffers