Little refactor on some functions.