More updates

Hopefully code is more readable and safe.