Some fixes got from main repo PRs.
Signed-off-by: Antes <antes@simplemachines.org>