Code refactoring

Clean up warnings/issues