Many small fixes for logstic regression