Fix up compiling errors caused by introduced code

This mostly involved copy+pasting sections from the keithbennett/keepassx code base.