Important bug fixes

Might need mocking out datetime