Cleanup code according to comments of jpardogo