Minor improvements, still needs testing