a lot of fixes, improved storaging of records