Fleshed out logging and added loginit()